<?php

class nn{
    public $name="nullnamne";
    public $age="28";
    public $color="red";
    public function jsonSerialize(){
        echo $this->name."
        ".$this->age;

}
}

$cc=serialize(new nn);
var_dump($cc);
echo json_encode($cc);

